<!DOCTYPE html>
<html>
{include file="head.html"}
<body>
<div class="body">
<div class="header" >
    <a href="{$appshop}?m=shop_product"  class="left-btn"><span class="iconfont icon-back"></span></a>
    <div class="title">产品编辑</div>
    <a class="right-btn pointer" href="{$appshop}?m=shop_product&a=add"><span class="iconfont icon-write"></span></a>
  </div>
<div class="main-body ">
<div class="row">
 
 

<div class="rbox">
 
<form method="post" id="xform"   action="{$shopadmin}?m=shop_product&a=save">
<input type="hidden" name="id" value="{$data.id}" />
 
<table width="100%" border="0" class="table table-bordered">
  <tr>
    <td width="60" align="right"> 标题：</td>
    <td  ><input name="title" type="text" id="title" value="{$data.title}" class="w98"></td>
  </tr>
  
  
  
  <tr>
    <td align="right">大类：</td>
    <td>
    <select name="catid" id="catid" class="w98">
    <option value="0">请选择</option>
    {foreach item=c from=$cat_list}
                <option value="{$c.catid}" {if $data.catid eq $c.catid} selected="selected"{/if}>{$c.cname}</option>
                {foreach item=c_2 from=$c.child}
                	<option value="{$c_2.catid}" {if $data.catid eq $c_2.catid} selected="selected"{/if} class="o_c_2">|__{$c_2.cname}</option>
                    {foreach item=c_3 from=$c_2.child}
                    <option value="{$c_3.catid}" {if $data.catid eq $c_3.catid} selected="selected"{/if} class="o_c_3"> |____{$c_3.cname}</option>
                    {/foreach}
                {/foreach}
                {/foreach}
    </select>
    
    
    
    </td>
  </tr>
  
  <tr>
    <td align="right">小类：</td>
    <td>
    <select name="shop_cid" id="shop_cid" class="w98">
    <option value="0">请选择</option>
    {foreach item=c from=$shop_cat_list}
                <option value="{$c.id}" {if $data.shop_cid eq $c.id} selected="selected"{/if}>{$c.title}</option>
                {foreach item=c_2 from=$c.child}
                	<option value="{$c_2.id}" {if $data.shop_cid eq $c_2.id} selected="selected"{/if} class="o_c_2">|__{$c_2.title}</option>
                    
                {/foreach}
                {/foreach}
    </select>
    
    
    
    </td>
  </tr>
  
  <tr>
	<td>价格：</td>
    <td><input type="text" name="price" value="{$data.price}" class="w98"/></td>
</tr>


 

<tr>
	<td>库存数量：</td>
    <td><input type="text" name="total_num" class="w98" value="{$data.total_num}" /></td>
</tr>


<tr>
	<td>推荐</td>
    <td> <input type="radio" name="is_recommend" {if $data.is_recommend neq 1} checked{/if} value="0"> 不推荐 <input type="radio" name="is_recommend" {if $data.is_recommend eq 1} checked{/if} value="1">推荐 </td>
</tr>

 

  <tr>
              <td>图片：</td>
              <td> <div id="up1" url="/index.php?m=upload&a=uploadtao&dir=shop_product&id={$data.id}">
    	<div class="btn-upload">
          <input type="file" name="upimg" id="ud"  class="btn-upload-file" onChange="uploadimg('up1')">
         </div>
 
          <input type="hidden" name="imgurl" class="imgurl" value="{$data.imgurl}">
          <span class="imgShow">
          {if $data.imgurl}
          <img src="{$data.imgurl|images_site}.100x100.jpg">
          {/if}
          </span>
      </div></td>
            </tr>
  
  
  
   
  <tr>
    
    <td colspan="2"><textarea name="description" id="description" placeholder="描述"  style="width:98%; height:60px;">{$data.description}</textarea></td>
  </tr>
   
  <tr>
            	<td colspan="2"><script type="text/html" name="content" id="content">{$data.content}</script></td>
            </tr>
            
</table>
 
<div class="form-btns">
 <button id="submit" type="button" name="button" class="btn btn-larger btn-success" >提交</button> 
</div>
</form>
</div>
{php loadEditor();} 
<script src="/plugin/skyweb/lrz.mobile.min.js"></script>
<script src="/static/js/upload_wap.js"></script>
<script>
 
$(function(){
 	var editor=UE.getEditor('content',options);
	$("#submit").bind("click",function(e){
	 
		if($("#catid").val()==0){
			$("#catid").focus();
			skyToast('分类不能为空');
			return false;
		}
		
		if($("#title").val()==""){
			$("#title").focus();
			skyToast('标题不能为空');
			return false;
		}
		
		$.post("{$appshop}?m=shop_product&a=save&ajax=1",$("#xform").serialize(),function(data){
			if(data.error){
				skyToast(data.message);
			}else{
				skyToast('保存成功');
			}
		});
	});
});
$(function(){
  

/*初始化载入属性*/
	$.get("{$appadmin}?m=product&a=attr&id={$data.id}&cat_id="+$("#attr_cat_id").val(),function(data){
				$("#attr_html").html(data);
				ajax_jsa();		
		});
	/*属性载入完毕*/
	
	$("#attr_cat_id").bind("change",function(){
		$.get("{$appadmin}?m=product&a=attr&id={$data.id}&cat_id="+$(this).val(),function(data){
				$("#attr_html").html(data);
				ajax_jsa();		
		});
	});
	
	$(".attr_item_add").on("click",function(e){
		var obj=$(this).parent(".attr_item");
		var o_t=obj.find(".attr_item_list");
		var a_len=obj.find(".attr_item_li").length;
		var html=obj.find(".attr_item_copy").html();
		html = html.replace(/\[@\]/,"["+a_len+"]");
		obj.find(".attr_item_list").append('<div class="attr_item_li">'+html+'</li>');
	});
	
	$(".attr_item_remove").on("click",function(e){
		$(this).parents(".attr_item_li").remove();
	});
	
	 
	
});
</script>
 
{include file='footer.html'}